<template>
  <div>
    <el-card v-if="labDesign.switch">设计模式不展示</el-card>
    <el-dialog :visible.sync="visible" center
               :title="element.props.title"
               :width="element.props.width"
               :full-screen="element.props.fullscreen"
               append-to-body destroy-on-close :close-on-click-modal="false" :close-on-press-escape="false"
      >
      <lab-view key="windowRef" :element="windowForm" :model-data="windowData" showView />
    </el-dialog>
  </div>
</template>

<script>
import LabBase from "../../mixins/LabBase";
import LabEvent from "../../mixins/LabEvent";

export default {
  name: "LabWindow",
  mixins: [LabBase,LabEvent],
  data() {
    return {
      visible: false,
      windowData: {},
      windowForm: { props: {}}
    }
  },
  methods: {
    open(element,data, conf) {
      if (!this.$Util.isEmpty(element)) {
        this.$Util.copyAttr(element,this.windowForm,null,this)
      }
      if (!this.$Util.isEmpty(data)) {
        this.$Util.copyAttr(data,this.windowData,null,this)
      }
      if (!this.$Util.isEmpty(conf)) {
        this.$Util.copyAttr(conf,this.element.props,null,this)
      }
      this.visible = true
    },
    close(){
      this.visible = false
      this.$Util.cleanObj(this, this.windowData)
      this.$Util.cleanObj(this, this.windowForm)
    }
  }
}
</script>

<style scoped>

</style>
